<?php

class Application_Form_Receiver extends Zend_Form
{
    private $province = array(
        "Aceh","Bali","Banten","Bengkulu","D.I. Yogyakarta","D.K.I. Jakarta","Gorontalo","Jambi",
        "Jawa Barat","Jawa Tengah","Jawa Timur","Kalimantan Barat","Kalimantan Selatan",
        "Kalimantan Tengah","Kalimantan Timur","Kepulauan Bangka Belitung","Kepulauan Riau",
        "Lampung","Maluku","Maluku Utara","Nusa Tenggara Barat","Nusa Tenggara Timur","Papua",
        "Papua Barat","Riau","Sulawesi Barat","Sulawesi Selatan","Sulawesi Tengah","Sulawesi Tenggara",
        "Sulawesi Utara","Sumatera Barat","Sumatera Selatan","Sumatera Utara"
    );

    public function init()
    {
        //Hidden text field to pass id value
        //ID must be integer


        //Shop's name
        $receiver_name = new Zend_Form_Element_Text("receiver_name");
        $receiver_name->setLabel("Nama Calon Penerima")
                ->setRequired("true")
                ->addFilter("StripTags")
                ->addFilter("StringTrim")
                ->addValidator("NotEmpty")
                ->setAttrib("maxLength", "30")
                ->addErrorMessages(array("NotEmpty" => "Mohon isi nama penerima"));

        $receiver_zip = new Zend_Form_Element_Text("receiver_zip");
        $receiver_zip->setLabel("Kode Pos Calon Penerima")
             ->setRequired("true")
             ->addFilter("StripTags")
             ->addFilter("StringTrim")
             ->addValidator("NotEmpty")
             ->addValidator("Digits")
             ->setAttrib("maxLength","5")
             ->addErrorMessages(array("NotEmpty"=>"Mohon isi kode pos dengan benar"));

        //Shop's address
        $receiver_address = new Zend_Form_Element_TextArea("receiver_address");
        $receiver_address->setLabel("Alamat Calon Penerima")
             ->addFilter("StripTags")
             ->addFilter("StringTrim")
             ->setAttrib("cols","30")
             ->setAttrib("rows","4")
             ->setRequired()
             ->addValidator("NotEmpty")
             ->addErrorMessages(array("NotEmpty" => "Mohon isi alamat penerima"));

        //Shop's city
        $receiver_city = new Zend_Form_Element_Text("receiver_city");
        $receiver_city->setLabel("Kota Calon Penerima")
             ->setRequired("true")
             ->addFilter("StripTags")
             ->addFilter("StringTrim")
             ->addValidator("NotEmpty")
             ->setAttrib("maxLength","15")
             ->addErrorMessages(array("NotEmpty"=>"Mohon isi kota penerima"));

        //Shop's province
        $provinces = array();
        foreach($this->province as $val){
            $provinces[$val] = $val;
        }
        $provinces["Lainnya"] = "Lainnya";
        $receiver_province = new Zend_Form_Element_Select("receiver_province");
        $receiver_province->setLabel("Provinsi Calon Penerima")
             ->setRequired()
             ->addMultiOptions($provinces);
         $penerima = new Zend_Form_Element_MultiCheckbox('penerima');

	$penerima->addMultiOption('penerima','Detail penerima sama dengan detail pembeli')
                ->setAttrib("onClick","checkPenerima();")
                ->setAttrib('id','penerima');
        //Submit button
        $submit = new Zend_Form_Element_Submit("submit");
        $submit->setAttrib("id","submit");

        //Reset button
        $reset = new Zend_Form_Element_Reset("reset");
        $reset->setAttrib("id","reset");

        //Add all elements to form
        $this->addElements(array($receiver_name,$receiver_address,$receiver_city,$receiver_zip,$receiver_province,$penerima,$submit,$reset));
    }


}

